package com.example.sxmall.controller.shopCart;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * @Author: yt
 * @Date: 2021/08/02/9:00
 * @Description: 商品相关枚举
 */
public interface ProductEnums {

    @Getter
    @AllArgsConstructor
    enum ProductStatusEnum {

        /**
         * 商品状态
         */
        WAIT_PAY        (1, "待支付"),
        WAIT_SEND       (2, "待发货"),
        WAIT_ACCEPT     (3, "待收货"),
        SUCCESSFUL_DEAL (4, "交易成功"),
        CLOSE_DEAL      (5, "交易关闭"),
        UNKNOWN         (-99, "未知"),
        ;

        private final Integer type;
        private final String typeName;

        public static ProductStatusEnum getEnumByTypeName(String typeName) {
            for (ProductStatusEnum ProductStatusEnum : ProductStatusEnum.values()) {
                if (ProductStatusEnum.getTypeName().equals(typeName)) {
                    return ProductStatusEnum;
                }
            }
            return UNKNOWN;
        }

        public static ProductStatusEnum getEnumByType(Integer type) {
            for (ProductStatusEnum ProductStatusEnum : ProductStatusEnum.values()) {
                if (ProductStatusEnum.getType().equals(type)) {
                    return ProductStatusEnum;
                }
            }
            return UNKNOWN;
        }
    }

    @Getter
    @AllArgsConstructor
    enum ProductButtonEnum {

        /**
         * 商品按钮
         */
        ADD_CART                 (1, "加入购物车", 1),
        BUY_IMMEDIATELY          (2, "立即购买", 2),
        SELF_PURCHASE_MONEY      (10, "自购省钱", 1),
        SHARE_MAKE_MONEY         (11, "分享赚钱", 2);

        private final Integer type;
        private final String typeName;
        private final Integer sort;

        public static ProductButtonEnum getEnumByType(Integer type) {
            for (ProductButtonEnum productButtonEnum : ProductButtonEnum.values()) {
                if (productButtonEnum.getType().equals(type)) {
                    return productButtonEnum;
                }
            }
            return null;
        }

        public static ProductButtonEnum getEnumByTypeName(String typeName) {
            for (ProductButtonEnum productButtonEnum : ProductButtonEnum.values()) {
                if (productButtonEnum.getTypeName().equals(typeName)) {
                    return productButtonEnum;
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    enum ProductLabelEnum {

        /**
         * 商品标签
         */
        BEEN_DELIVERY   (1, "已发货"),
        RETURNING       (2, "退款中"),
        RETURNED        (3, "已退货"),
        BEEN_REFUND     (5, "退款成功");

        /**
         * 类型
         */
        private final Integer type;
        /**
         * 类型名称
         */
        private final String typeName;

        public static ProductLabelEnum getEnumByTypeName(String typeName) {
            for (ProductLabelEnum productLabelEnum : ProductLabelEnum.values()) {
                if (productLabelEnum.getTypeName().equals(typeName)) {
                    return productLabelEnum;
                }
            }
            return null;
        }

        public static ProductLabelEnum getEnumByType(Integer type) {
            for (ProductLabelEnum productLabelEnum : ProductLabelEnum.values()) {
                if (productLabelEnum.getType().equals(type)) {
                    return productLabelEnum;
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    enum ProductTypeEnum {

        /**
         * 商品类型
         */
        Product_ORDINARY      (1, "普通商品"),
        Product_SHOP_GIFT     (10, "赠品")
        ;

        /**
         * 类型
         */
        private final Integer type;
        /**
         * 类型名称
         */
        private final String typeName;

        public static ProductTypeEnum getEnumByTypeName(String typeName) {
            for (ProductTypeEnum ProductTypeEnum : ProductTypeEnum.values()) {
                if (ProductTypeEnum.getTypeName().equals(typeName)) {
                    return ProductTypeEnum;
                }
            }
            return null;
        }

        public static ProductTypeEnum getEnumByType(Integer type) {
            for (ProductTypeEnum productTypeEnum : ProductTypeEnum.values()) {
                if (productTypeEnum.getType().equals(type)) {
                    return productTypeEnum;
                }
            }
            return null;
        }
    }

    @Getter
    @AllArgsConstructor
    enum ProductPicTypeEnum {

        /**
         * 商品类型
         */
        ROTATION     (1, "轮播图"),
        DETAIL       (2, "详情页长图")
        ;

        /**
         * 类型
         */
        private final Integer type;
        /**
         * 类型名称
         */
        private final String typeName;
    }

    @Getter
    @AllArgsConstructor
    enum ProductOnShelfEnum {

        /**
         * 商品类型
         */
        ON_SHELF        (1, "上架"),
        OFF_SHELF       (2, "下架")
        ;

        /**
         * 类型
         */
        private final Integer type;
        /**
         * 类型名称
         */
        private final String typeName;
    }
}
